#include <iostream>
#include <unistd.h>

using namespace std;

int main()
{
	pid_t id = fork();
	if(id < 0)
	{
		perror("fail fork()");
		return 1;
	}
	else if(id > 0)
	{
		int i = 3;
		while(i--)
		{
			sleep(1);
			cout<<"父进程ing ppid->"<<getppid()<<"pid->"<<getpid()<<endl;
		}
	}
	else
	{
		int i = 10;
		while(i--)
		{
			sleep(1);
			cout<<"子进程ing ppid->"<<getppid()<<"pid->"<<getpid()<<endl;
		}
	}
	return 0;
}

